package com.yuanfeng.commoms.rocketmq.config;

import org.apache.rocketmq.common.message.Message;

public class JmsConfig {

    //指定NameServer地址，多个地址以 ; 隔开
    //public static final String NAME_SERVER = "192.168.100.141:9876;192.168.100.142:9876;192.168.100.149:9876";

    public static final String DEFAULT_ORDERLY_TOPIC = "default_orderly_topic_110";

    public static final String DEFAULT_TRANSACTION_TOPIC = "default_transaction_topic_110";

    public static final String DEFAULT_TAGS = "default_tags";


    public static final String DEFAULT_ES_TOPIC = "default_es_topic";

    public static final String DEFAULT_SYSLOG_TOPIC = "default_syslog_topic";

    //producerGroup

    public static String PRODUCER_GROUP = "simple_producer_group";

    public static String ORDERLY_PRODUCER_GROUP = "orderly_producer_group";

    public static String TRANSACTION_PRODUCER_GROUP = "transaction_producer_group";

    public static String PRODUCER_GOODS_ES_GROUP = "goods_es_group";

    public static String PRODUCER_SYS_LOG_GROUP = "sys_log_group";

    //consumerGroup
    public static String CONSUMER_GOODS_ES_GROUP = "consumer_goods_es_group";

    public static String CONSUMER_SYS_LOG_GROUP = "consumer_log_group";

    public static String CONSUMER_GROUP = "simple_consumer_group";

    public static String CONSUMER_ORDERLY_GROUP = "orderly_consumer_group";

    public static String CONSUMER_TRANSACTION_GROUP = "transaction_consumer_group";

    public static class Utils {
        /**
         * 普通消息
         * @param msg
         * @return
         */
        public static Message buildDefaultMessage (String msg) {
            Message message = new Message(JmsConfig.DEFAULT_ES_TOPIC,DEFAULT_TAGS, msg.getBytes());
            return message;
        }

        /**
         * 队列消息
         * @param msg
         * @return
         */
        public static Message buildOrderlyMessage(String msg) {
            Message message = new Message(JmsConfig.DEFAULT_ORDERLY_TOPIC,DEFAULT_TAGS, msg.getBytes());
            return message;
        }

        /**
         * 事务消息
         * @param msg
         * @return
         */
        public static Message buildTransactionMessage(String msg) {
            Message message = new Message(JmsConfig.DEFAULT_TRANSACTION_TOPIC,DEFAULT_TAGS, msg.getBytes());
            return message;
        }

        /**
         * es消息
         * @param msg
         * @return
         */
        public static Message buildEsMessage(String msg) {
            Message message = new Message(JmsConfig.DEFAULT_ES_TOPIC,DEFAULT_TAGS, msg.getBytes());
            return message;
        }

        /**
         * 操作日志消息
         *
         * @param msg
         * @return
         */
        public static Message buildSysLogMessage(String msg) {
            Message message = new Message(JmsConfig.DEFAULT_SYSLOG_TOPIC, DEFAULT_TAGS, msg.getBytes());
            return message;
        }
    }
}
